#include "HashTable.hpp"
#include <iostream>

void test1(){
  HashTable<int,int> ht;
  int arr[] = {1,11,4,15,26,7,44,7};
  for(auto e : arr)
  {
    ht.insert(make_pair(e,e));
  }
  ht.printHT();
  ht.insert(make_pair(9,9));
  ht.printHT();
  ht.erase(4);
  cout << ht.find(44) << endl;
  cout << ht.find(4) << endl;
  ht.insert(make_pair(-2,-2));
  ht.printHT();
  cout << ht.find(-2) << endl;
}

void test2(){
  HashTable<string, int> counter;
  string arr[] = { "苹果", "西瓜", "苹果", "西瓜", "苹果", "苹果", "西瓜","苹果", "香蕉", "苹果", "香蕉"};
  //方法一：上一章讲过的方法
  for(string &e : arr)
  {
    auto ret = counter.find(e);
    if(ret)
    {
      ++ret->_kv.second; 
    } 
    else{
      counter.insert(make_pair(e,1));                                                                                           }
  }
  counter.printHT();
}

int main(){
  //test1();
  test2();
  return 0;
}
